#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<map>
using namespace std;
int letter[30];
typedef long long LL;
char arr[1010];
map<char, int>mp;
string s1, s2;
void fun()
{
	int k = 0;
	for (int i = 'A'; i < 'A' + 26; i++) {
		letter[i] = k++;
	}
}
void fun1()
{
	int k = 0;
	for (int i = 0; i < 26; i++) {
		char x = (char)('A' + i);
		mp[x] = k++;
	}
}
int main()
{
	fun1();
	/*for (int i = 'A'; i < 'A' + 26; i++) {
		cout << letter[i] << " ";
	}*/
	while (cin >> s1 >> s2) {
		memset(arr, ' ', sizeof(arr));
		LL sum = 0;
		int n1 = s1.size();
		int n2 = s2.size();
		int k = n1 - 1;
		//cout << mp['A'] << endl;
		for (int i = 0; i < n1; i++) {
			//cout << mp[s1[i]] << " ";
			sum += (LL)mp[s1[i]] * (int)pow(26, k--);
		}
		//cout << endl;
		k = n2 - 1;
		for (int i = 0; i < n2; i++) {
			//cout << mp[s2[i]] << " ";
			sum += (LL)mp[s2[i]] * (int)pow(26, k--);
		}
		cout << sum << endl;
		if (!sum) {
			cout << "A" << endl;
			continue;
		}
		LL temp = sum;
		int i = 0;
		while (temp) {
			LL z = temp % 26;
			arr[i++] = (char)('A' + z);
			temp /= 26;
		}
		for (int j = i - 1; j >= 0; j--) {
			cout << arr[j];
		}
		cout << endl;
	}
	return 0;
}